var __post_content__ = '';
var url_prefix = dao.getUrlPrefix();
if (url_prefix == null || url_prefix == "") {
	alert("Please specify URL Prefix in options");
}
	
function post_content(url, content) {
	__post_content__ = content;
	var spider = nest.callSpider();
	spider.eat(url, continue_post_session);
}

function continue_post_session(url, hasError, content) {
	if (hasError) {
		error('Error');
		error(content);
		return;
	}
	var session = get_selected_session();
	sis_set_content(url_prefix, content);
	var formhash = sis_get_formhash();
	if (formhash == null) {
		error('Cannot find formhash');
		return;
	}
	var form_action = sis_get_formaction();
	if (form_action == null) {
		error('Cannot find form action');
		return;
	}

	var form = document.getElementById("post_form");
	sis_direct_reply_form(form, form_action, formhash, __post_content__, post_finish);
}

function post_finish() {
	if (this.status == 302) {
		log('Post success');
	} else {
		error('Post fail: ' + this.status);
	}
}

